<div class="layui-card">
  <div class="layui-card-body" style="border-bottom: 1px solid #f6f6f6;">
	  <div class="layui-row">
		  <div class="layui-btn-group larry-group">
                <button class="layui-btn" onclick="javascript:layer.open({title:'增加',type:2,area: ['100%', '100%'],content:'<{:url('shop/add')}>'});">
                    <i class="layui-icon"></i><cite>增加</cite>
                </button>
                <!-- <button class="layui-btn layui-btn-normal" data-type="edit"><i class="layui-icon"></i><cite>修改用户</cite></button>
                <button class="layui-btn layui-btn-danger" data-type="del"><i class="layui-icon"></i><cite>删除用户</cite></button> -->
          </div>
	  </div>
  </div>
  <div class="layui-card-body">
	  <div class="layui-row layui-form" id="form">
		 <div class="layui-col-lg2">
			 <input type="text" name="keyword" placeholder="请输入商家店名/电话" autocomplete="off" class="layui-input">
		</div>
		<div class="layui-col-lg1">
		  <select name="status">
			<option value="">是否冻结</option>
			<option value="0">正常</option>
			<option value="1">冻结</option>
		  </select>
		</div>
		<div class="layui-col-lg1">
		  <select name="is_active">
			<option value="">是否激活</option>
			<option value="0">未激活</option>
			<option value="1">已激活</option>
		  </select>
		</div>
		<div class="layui-col-lg1">
		  <select name="shop_status">
			<option value="">是否认证资料</option>
			<option value="0">未认证</option>
			<option value="1">申请中</option>
			<option value="2">已认证</option>
		  </select>
		</div>
		<div class="layui-col-lg1">
		  <button class="layui-btn layui-btn-normal" onclick="search()">搜索</button>
		</div>
	  </div>
	  <div class="layui-row">
			  <table class="layui-hide" lay-filter="table" id="table"></table>
	  </div>
  </div>
</div>

<script type="text/html" id="barDemo">
  <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
  <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
  <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<script>
layui.use(['table','form','larry'], function(){
    var form = layui.form;
    var table = layui.table;
    var $ = layui.$;
    var larry = layui.larry;
    form.render('select');
    search = function(){
        var url = "/shop/lists";
        var data = $("#form").find("[name]");
        var where = {};
        data.each(function(i,e){
            where[$(e).attr('name')] = $(e).val();
        });
        table.render({
            elem: '#table'
            ,url:url
            ,where:where
            ,method:'post'
            ,cellMinWidth:180
            ,page: true
            ,cols: [[
                //{type:'checkbox'},
                {field:'id', title: 'ID',width:80, sort: true,title:'ID'}
                ,{field:'title', title: '店铺名称'}
                ,{field:'phone', title: '商家电话'}
                ,{field:'address', title: '商家地址'}
                ,{field:'status', title: '是否冻结'}
                ,{field:'is_active', title: '是否激活'}
                ,{field:'shop_status', title: '是否认证'}
                ,{field:'create_time', title: '注册时间'}
                ,{field:'service_end_time', title: '服务到期时间'}
                ,{field:'action', title: '操作',width:178, align:'center', toolbar: '#barDemo'}
            ]]
        });
    };
    search();
      //监听工具条
      table.on('tool(table)', function(obj){
        var data = obj.data;
        if(obj.event === 'detail'){
            layer.open({
                title:'查看',
                type:2,
                area: ['100%', '100%'],
                content:'/shop/detail/id/'+data.id
            });
        } else if(obj.event === 'del'){
          layer.confirm('确认要删除吗?', function(index){
            $.ajax({
                url:"/shop/del",
                method:"post",
                dataType:"json",
                data:{id:data.id},
                success:function(res){
                    larry.my.action(res);
                    if(res.code==0){
                        obj.del();
                    }
                }
            });
          });
        } else if(obj.event === 'edit'){
            layer.open({
                title:'编辑',
                type:2,
                area: ['100%', '100%'],
                content:'/shop/edit/id/'+data.id
            });
        }
      });
});
</script>
